import {toast} from 'nc-lightapp-front';
import proFetch from '../../../../public/functions/project-fetch';

export default function addConfirmAsk() {
    const {termtype, remenddate, remmonthtext, selectedunit, selradiobtn, json} = this.state;
    const checkedData = this.props.table.getCheckedRows('contopinionadd');
    if (!checkedData.length) {
        toast({color: 'warning', content: json['cm6011-000010']}); /* 国际化处理： 请选择要操作的条目!*/
        return;
    }

    proFetch({
        url: '/nccloud/hrcm/contopinion/OpinionRemcAddOkAgrAction.do',
        body: {
            contopinionadd: {
                rows: checkedData.map((item) => item.data)
            },
            pk_org: this.props.orgVal.refpk,
            termtype,
            remenddate,
            remmonthtext,
            selectedunit,
            selradiobtn
        }
    }).then((res) => {
        if (res.success) {
            this.closeModal();
            this.props.confirmAskAction && this.props.confirmAskAction();
        }
    });
}
